package eu.news.kits;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

public class JsonUtil {
	Map<String, Object> map=new HashMap<String, Object>();
	
	public Object put(String name,Object value){
		return map.put(name, value);
	}
	
	@Override
	public String toString() {
		Iterator<Entry<String, Object>> it=map.entrySet().iterator();
		StringBuffer buffer = new StringBuffer("{");
		while(it.hasNext()){
			Entry<String, Object> entry = it.next();
			buffer.append("\""+entry.getKey()+"\":\""+entry.getValue().toString()+"\",");
		}
		if(buffer.length()>1)
			buffer.deleteCharAt(buffer.length()-1);
		buffer.append("}");
		return buffer.toString();
	}

	public void clear(){
		map.clear();
	}
	
	public static void main(String[] args){
		JsonUtil json=new JsonUtil();
		json.put("1", "jk");
		json.put("name", "name");
		System.out.println(json);
	}
}
